﻿using SuperMap.UI;
using System;
using System.Collections.Generic;
using WeifenLuo.WinFormsUI.Docking;

namespace Ycjw.PipeLine.Map.Basic.Results
{
    /****************************************************************************************/
    /*
    功    能:
    作    者: RenZachary
    联系方式: rzcgis@foxmail.com（QQ455745253）
    生成日期: 2021年3月24日
    修改日志: 
    版权说明: @2021 西安云创经纬信息科技有限公司 版权所有 All right reserved.
    注    意: 本内容仅限于云创经纬公司内部使用，禁止用于商业目的。
    */
    /****************************************************************************************/
    public partial class ResultWindow : ToolWindowExtend
    {
        /// <summary>
        /// 存储参数
        /// </summary>
        private SortedDictionary<string, object> m_BaseParams = new SortedDictionary<string, object>();
        /// <summary>
        /// 设置参数
        /// </summary>
        /// <param name="key">参数名</param>
        /// <param name="value">参数值</param>
        public void SetParams(string key,object value)
        {
            if (m_BaseParams.ContainsKey(key))
            {
                return;
            }
            m_BaseParams.Add(key,value);
        }
        /// <summary>
        /// SceneControl对象
        /// </summary>
        protected SceneControl SceneControl
        {
            get
            {
                if (m_BaseParams.ContainsKey("SceneControl"))
                    return m_BaseParams["SceneControl"] as SceneControl;
                return null;
            }
        }
        /// <summary>
        /// 构造
        /// </summary>
        public ResultWindow()
        {
            InitializeComponent();
            ///关闭按钮可见、可用
            this.CloseButtonVisible = true;
            this.CloseButton = true;
            this.DockAreas = DockAreas.DockLeft 
                | DockAreas.DockRight
                | DockAreas.DockTop
                | DockAreas.DockBottom 
                | DockAreas.Document
                | DockAreas.Float;
        }
        /// <summary>
        /// 显示数据非BasicToolBar 必须实现此方法
        /// </summary>
        /// <param name="data"></param>
        public virtual void ShowData(object data)
        {
            throw new Exception("未实现Ycjw.PipeLine.Map.Tools.Results.ResultWindow.ShowData");
        }
        /// <summary>
        /// 导出Excel按钮
        /// </summary>
        protected Sunny.UI.UISymbolButton uiSymbolButtonExportToExcel;
        /// <summary>
        /// 导出图片按钮
        /// </summary>
        protected Sunny.UI.UISymbolButton uiSymbolButtonExportToImage;
        protected void CreateExportExcelButton()
        {
            this.uiSymbolButtonExportToExcel = new Sunny.UI.UISymbolButton
            {
                Cursor = System.Windows.Forms.Cursors.Hand,
                Dock = System.Windows.Forms.DockStyle.Bottom,
                Font = new System.Drawing.Font("微软雅黑", 12F),
                Location = new System.Drawing.Point(0, 415),
                MinimumSize = new System.Drawing.Size(1, 1),
                Name = "uiSymbolButtonExportToExcel",
                Size = new System.Drawing.Size(800, 20),
                Symbol = 61582,
                TabIndex = 0,
                Text = "导出到Excel"
            };
            this.Controls.Add(this.uiSymbolButtonExportToExcel);
        }
        /// <summary>
        /// 增加导出图片和Excel按钮
        /// </summary>
        protected void CreateExportImageAndExcelButton()
        {
            Sunny.UI.UIPanel panel = new Sunny.UI.UIPanel
            {
                Dock = System.Windows.Forms.DockStyle.Bottom,
                Height = 20
            };
            this.Controls.Add(panel);
            this.uiSymbolButtonExportToExcel = new Sunny.UI.UISymbolButton
            {
                Dock = System.Windows.Forms.DockStyle.Fill,
                Cursor = System.Windows.Forms.Cursors.Hand,
                Font = new System.Drawing.Font("微软雅黑", 12F),
                Location = new System.Drawing.Point(0, 415),
                MinimumSize = new System.Drawing.Size(1, 1),
                Name = "uiSymbolButtonExportToExcel",
                Size = new System.Drawing.Size(800, 20),
                Symbol = 61582,
                TabIndex = 0,
                Text = "导出到Excel",
                RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None,
                RadiusSides = Sunny.UI.UICornerRadiusSides.None
            };
            panel.Controls.Add(this.uiSymbolButtonExportToExcel);

            this.uiSymbolButtonExportToImage = new Sunny.UI.UISymbolButton
            {
                Dock = System.Windows.Forms.DockStyle.Left,
                Cursor = System.Windows.Forms.Cursors.Hand,
                Font = new System.Drawing.Font("微软雅黑", 12F),
                Location = new System.Drawing.Point(0, 415),
                MinimumSize = new System.Drawing.Size(1, 1),
                Name = "uiSymbolButtonExportToImage",
                Size = new System.Drawing.Size(800, 20),
                Symbol = 61893,
                TabIndex = 1,
                Text = "导出图片",
                RectSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.None,
                RadiusSides = Sunny.UI.UICornerRadiusSides.None
            };
            panel.Controls.Add(this.uiSymbolButtonExportToImage);

            this.SizeChanged += ResultWindow_SizeChanged;
        }
        /// <summary>
        /// 窗体发生变化时候按钮自动缩放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResultWindow_SizeChanged(object sender, EventArgs e)
        {
            uiSymbolButtonExportToExcel.Width = this.Width / 2;
            uiSymbolButtonExportToImage.Width = this.Width / 2;
        }
    }
}
